public class Demo2 {
    public static void main(String[] args) {
        Thread thread = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                System.out.println(Thread.currentThread().getName()+ ":我还存活");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName() + ":我即将死去");
        });

        System.out.println(Thread.currentThread().getName() + ": 状态" + thread.getState());

        //启动线程
        thread.start();
        boolean flg = thread.isAlive();  //是否存活
        System.out.println(Thread.currentThread().getName() + ": 状态：" + thread.getState());
    }
}
